package com.example.day22;

/**
 * @author Lenovo
 */
public class eatable {
    void eat() {

    }
}

public static void main(String[] args) {
    class EatableImpl extends eatable {
        @Override
        public void eat() {
            System.out.println("一天一苹果，医生远离我");
        }
    }
    //测试类
    public class EatableDemo {
        public void main(String[] args) {
            //在主方法中调用useEatable方法
            eatable e = new EatableImpl();
            useEatable(e);

            //匿名内部类
            useEatable(new eatable() {
                public void eat() {
                    System.out.println("一天一苹果，医生远离我");

            });

            //Lambda表达式
            useEatable(() -> {
                System.out.println("一天一苹果，医生远离我");

            });


        private static void useEatable(eatable e) {
            e.eat();
        }
    }

